import axios from './index'

export const CommApi = (id) =>
    axios({
        url: 'http://172.16.101.97:8001/goodsmanage/findGoods',
        method: 'GET',
        params: {
            goods_status: id

        }
    })

export const updateGoodsClass = (list) =>
    axios({
        url: 'http://172.16.101.97:8001/goodsClass/updateGoodsClass',
        method: 'post',
        data: {
            "classifyName": list[0],
            "classifyNameEn": list[1],
            "describtion": list[2],
            "userful": list[3]
        }
    })
// 上传分类
export const addGoodsClass = (list) =>
    axios({
        url: 'http://172.16.101.97:8001/goodsClass/addGoodsClass',
        method: 'post',
        data: {
            "classifyName": list[0],
            "classifyNameEn": list[1],
            "describtion": list[2],
            "userful": list[3]
        }

    })

// 上传商品
export const addGoods = (data) =>
    axios({
        url: 'http://172.16.101.97:8001/goodsmanage/addGoods',
        method: 'POST',
        data: {
            "shopId": data.shopId,
            "goodsPic": data.goodsPic,
            "chineseName": data.chineseName,
            "englishName": data.englishName,
            "goodsClassification": data.goodsClassification,
            "termOfValidity": data.termOfValidity,
            "singlepointNonDelivery": data.singlepointNonDelivery,
            "goodsType": data.goodsType,
            "cnGoodsDescription": data.cnGoodsDescription,
            "ukGoodsDescription": data.ukGoodsDescription,
            "productionDuration": data.productionDuration,
            "commoditySpecifications": data.commoditySpecifications,
            "goodsPrice": data.goodsPrice,
            "goodsInventory": data.goodsInventory,
            "goodsPackingFee": data.goodsPackingFee,
            "limitedTimeSale": data.limitedTimeSale,
            "limitedSupply": data.limitedSupply,
            "newGoods": data.newGoods,
            "specialtyGoods": data.specialtyGoods,
            "promotionGoods": data.promotionGoods,
            "shopStatus": data.shopStatus,
            "goodsSpecifications": data.goodsSpecifications,
            "goodsAttribute": data.goodsAttribute
        }

    }).then((res) => {
        console.log('成功', data, res)
    })
        .catch((err) => {
            console.log('失败', data, err)
        })

// 上传图片
export const fileImg = (img) =>
    axios({
        url: 'http://172.16.101.97:8001/goodsmanage/file',
        method: 'post',
        data: {
            file: img
        }

    }).then(res => {
        console.log(res);
    })
        .catch(err => {
            console.log(err);
        })
// 通过id查询商品
export const findGoodsbyId = (id) =>
    axios({
        url: 'http://172.16.101.97:8001/order/findGoodsbyId',
        method: 'get',
        params: {
            goodsId: id
        }

    }).then((res) => {
        console.log(res, id, "成功")
    })
        .catch((err) => {
            console.log(err, id, "失败")
        })
// 通过保存
export const outSuccess = () =>
    axios({
        url: 'http://172.16.101.63:8001/out/outSuccess',
        method: 'get',
        params: {

        }

    })
// 查询
export const findGoodsParticulars = (id) =>
    axios({

        url: 'http://172.16.101.63:8001/goodsmanage/findGoodsParticulars',
        method: 'post',
        data: {
            goods_id: id
        }

    })